package com.sx.baseproject.framework.adapter.binding;

import android.graphics.drawable.Drawable;
import android.text.TextUtils;

import androidx.annotation.StringRes;
import androidx.databinding.BindingAdapter;

import com.sx.widget.view.SettingBar;

public class SettingBarBinding {

    @BindingAdapter(value = {"setBarLeftText","setBarLeftTextValue","setBarLeftBold","setBarLeftDrawable","setBarRightText"},requireAll = false)
    public static void settingBar(SettingBar view, @StringRes int lt, String ltChar, boolean bold, Drawable leftDrawable, String rightText){
        if(view!=null){
            if(lt!=0){
                view.setLeftText(lt);
            }
            if(!TextUtils.isEmpty(ltChar)){
                view.setLeftText(ltChar);
            }
            if(leftDrawable!=null){
                view.setLeftIcon(leftDrawable);
            }
            view.getLeftView().getPaint().setFakeBoldText(bold);
            if(!TextUtils.isEmpty(rightText)){
                view.setRightText(rightText);
            }
        }
    }
}
